package com.iter.devbox.juc;

import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MyCyclicBarrier {
	
	public static void main(String[] args) throws InterruptedException {
		final CyclicBarrier cyclicBarrier = new CyclicBarrier(10);
        ExecutorService service = Executors.newCachedThreadPool();
 
        for (int i = 0; i < 10; i++) {
            service.execute(new Runnable() {
                @Override
                public void run() {
                    System.err.println("begin..........");
                    try {
                        cyclicBarrier.await();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    System.err.println("end............");
                }
            });
        }
        service.shutdown();
	}
}
